package com.example.myapplication

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.ViewGroup
import android.widget.Button
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        btn.setOnClickListener {
            textView.text = getString(R.string.btn_clicked)
        }

        //纯代码版实现简易版
//        val linearLayout=LinearLayout(this)
//        linearLayout.orientation=LinearLayout.VERTICAL
//        val textView=TextView(this)
//        textView.layoutParams=ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.WRAP_CONTENT)
//        textView.textSize=resources.getDimension(R.dimen.text_size)
//        textView.text=getString(R.string.my_first_hello_world)
//        textView.setTextColor(resources.getColor(R.color.skyblue))
//        linearLayout.addView(textView)
//        val button=Button(this)
//        button.width=ViewGroup.LayoutParams.MATCH_PARENT
//        button.height=ViewGroup.LayoutParams.WRAP_CONTENT
//        button.text=getString(R.string.button)
//        linearLayout.addView(button)
//        setContentView(linearLayout)
//        button.setOnClickListener {
//            textView.text=getString(R.string.btn_clicked)
//        }
//        val img=ImageView(this)
//        img.layoutParams=ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.WRAP_CONTENT)
//        linearLayout.addView(img)
//        setContentView(linearLayout)


//        val img=ImageView(this)
//        img.width=ViewGroup.LayoutParams.MATCH_PARENT




    }
}